﻿    <script type="text/javascript">
        $(document).ready(function () {
            var p = new singlepage();
            p.c = "Way.Bus.WMS.XHY.Controllers.PurchaseInOrderController";
            p.applyTo = "t1";
            p.ishelp = false;
            p.onForeigned = function (sender, fdata, rows) {
//                if (fdata.tablename.toString() == "Acc_Bus_BusinessCommodity" && sender.field.toString() == "MATERIALCODE") {
//                    var tt = p.datasource.post("VoliGetUnit", "MaterialsId=" + rows.ID + "");
//                    var row = sender.parent.selectrow();
//                    var on = sender.parent.geteditor("BATCHNO");
//                    var myDate = new Date();
//                    var year = String(myDate.getFullYear()).substr(2);
//                    var month = parseInt(parseInt(myDate.getMonth(), 10) + 1).toString();
//                    var day = myDate.getDate().toString();
//                    if (parseInt(month) <= 9) {
//                        month = '0' + month;
//                    }
//                    if (parseInt(day) <= 9) {
//                        day = '0' + day;
//                    }
//                    var pici = year + month + day; //String(myDate.getFullYear()).substr(2) + parseInt(parseInt(myDate.getMonth(), 10) + 1).toString() + myDate.getDate().toString();
//                    on.actions.setValue(on.target, pici, row);
//                    if (tt != "") {
//                        var eb = sender.parent.geteditor("MATERIALPACKID");
//                        eb.actions.setValue(eb.target, tt, row);
//                    }
//                    //grid.load({ total: tt.length, rows: tt });
//                }
                if (fdata.tablename.toString() == "Acc_WMS_InNotice" && sender.field.toString() == "SOURCECODE") {
                    var id = rows.ID;
                    //sender.parent.unionobj["SOURCEID"] = id;
                    var tt = p.datasource.post("GetNoticeStayGrid", "NoticeId=" + fdata.filedvalue + "");
                    if (tt != "[]") {
                        var grid = sender.parent.griditems["Way.Bus.WMS.Model.StockInNoticeMaterials"];
                        grid.insertRow(tt);
                    }
                }
            }
            //            p.onCommandClick = function (command, form, item) {
            //                if (command == "add" || command == "edit") {
            //                    var extend = form.griditems["Way.Bus.WMS.Model.StockInOrderMaterials"];
            //                    var out = form.griditems["Way.Bus.WMS.Model.StockInNoticeMaterials"];
            //                    out.toolbar([{
            //                        text: '发货',
            //                        iconCls: 'icon-add',
            //                        handler: function () {
            //                            var checkRows = out.getselectrows();
            //                            if (checkRows) {

            //                                var row = {
            //                                    F4: checkRows.F2,
            //                                    MCODE: checkRows.MCODE,
            //                                    FMODEL: checkRows.FMODEL,
            //                                    MATERIALCODE: checkRows.MATERIALCODE
            //                                }
            //                                extend.insertRow(row);
            //                            }
            //                            form.selectTab(0);
            //                        }
            //                    }]);
            //                }
            //            }

            p.init();
        });
      </script>
<div id="t1"></div>
